<!doctype html>
<html>
<head>
<title>解放号，可信的IT服务众包平台</title>
<meta property="qc:admins" content="231327022534627164672356375" />
<meta http-equiv="pragma" content="no-cache"/>
<meta http-equiv="cache-control" content="no-cache"/>
<meta http-equiv="expires" content="0"/>
<meta name="keywords" content="解放号,众包平台,众包网站,JointForce,众包,项目交易,外包,定制开发,软件开发,项目开发">
<meta name="description" content="解放号JointForce平台，提供设计、开发、测试、运维、运营、编辑等项目资源和人才资源，为企业、软件公司和软件开发人才提供一个可信IT服务众包平台。">
<link rel="shortcut icon" type="image/x-icon" href="https://www.jointforce.com/icon/logo.png"/>
<meta charset=UTF-8 />
<meta name="author" content="CSI"/>
<link rel="shortcut icon" type="image/x-icon" href="https://www.jointforce.com/icon/logo.png"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="renderer" content="webkit|ie-comp|ie-stand" />
<link rel="stylesheet" type="text/css" href="https://www.jointforce.com/styles/base.css" />
<link rel="stylesheet" type="text/css" href="https://www.jointforce.com/styles/common.css" />
<link rel="stylesheet" type="text/css" href="https://www.jointforce.com/styles/extends/loginreg/loginreg.css"/>
<script type="text/javascript" src="https://www.jointforce.com/js/lib/biz.jquery.js"></script>
<script type="text/javascript" src="../../js/extends/jquery/jquery-1.10.2.js"></script>
<style>
.ccs_banner{width:100%;height:300px;text-align:center;margin:auto;clear:both;background-color:#1D8CD3;}
.ccs_banner_img{width:100%;height:300px;margin:auto;clear:both;background:url(images/ccs_bg2.png) no-repeat center}
.ccs_banner img{margin:auto;clear:both;}

.box{position:relative;width:810px;height:510px;border:1px solid #f5f5f5;margin:auto;padding:2px;}
.repo{border:1px solid #fff;position:absolute;text-align:center;color:#fff;}
.operation{width:1000px;margin:auto}
</style>
</head>
<body>

<div id="hphead">
	<div class="hphead">
		<a href="https://www.jointforce.com/jfhome"><h1 id="hplogo">解放号 JointForce</h1></a>
		<ul id="nav">
			<li class="login"><a href="javascript:ajalogin();" id="btn-login-show"><i class="nav_icon_login"></i>登录</a></li>
			<li class="reg"><a target="_self" href="/register/index"><i class="nav_icon_reg"></i>注册</a></li>
			<li><a  href="https://www.jointforce.com/jfhome">首页</a></li>
	    	<li><a target="_blank" href="https://www.jointforce.com/jetchat"><i class="nav_icon_klinfo" style="display:none"></i>移动端</a></li>
	    	<li><a target="_blank" href="http://www.jointforce.com/jfperiodical/openhome?m=d03"><i class="nav_icon_jwk" style="display:none"></i>杰微刊</a></li>
			<li><a target="_blank" href="https://www.jointforce.com/jfportal/bbs?m=d05"><i class="nav_icon_bbs" style="display:none"></i>论坛</a></li>
			<li><a target="_blank" href="https://www.jointforce.com/jfportal/bbs?t=services&m=d04"><i class="nav_icon_space" style="display:none"></i>客服</a></li>
		</ul>
		<div class="clear"></div>
	</div>
</div>
<div id="operation" class="operation">
	
</div>
<div id="box" class="box">
	<div class=""></div>
</div>

</body>
<script type="text/javascript">
var level80 = "#3dc532";	
var level70 = "#01bceb";
var level60 = "#ffbc00";
var level59 = "#f37800";
var level0 = "#ffffff";
function getColor(score){
	var d = parseInt(score);
	if(score>=80){
		return level80;
	}else if(score>=70){
		return level70;
	}else if(score>=60){
		return level60;
	}else if(score>0){
		return level59;
	}else{
		return level0;
	}
}

var ww=800,hh=500;
function draw(c){
	var box = $("#box").empty();
	var q = Math.ceil(Math.sqrt(c));
	var cols = q;
	var rows = 1;
	var w = ww/cols;
	var h = hh/rows;
	var x=0;y=0;
	if(1<=c && c<=cols){//单排排列
		w = ww/cols;
		h = hh;
		for(var i=1;i<=c;i++){
			x=w*(i-1);
			y=0;
			drawbox(box,i,w,h,x,y,getRandScore());			
		}
	}else{//分层排列
		rows = Math.ceil(c/q);
		w = ww/cols;
		var m = c % q;//取模的余数
		if(m==0){
			w = ww/cols;
			h = q/c * hh;
			var c1=1;
			for(var i=1;i<=cols;i++){
				for(var j=1;j<=rows;j++){
					x=w*(i-1);
					y=h*(j-1);
					drawbox(box,c1++,w,h,x,y,getRandScore());			
				}
			}
		}else{
			var fullCols = Math.floor(c/q);//整列填满数
			//先把剩余的按比例画=m
			var leftCols = cols - fullCols;
			if(leftCols==1){
				//leftCols==1,m>1,在一列中分拆
				h = hh/m;			
				for(var i=1;i<=m;i++){
					x=0;
					y=h*(i-1);
					drawbox(box,i,w,h,x,y,getRandScore());			
				}
			}else if(leftCols>1){
				if(m==leftCols){
					//leftCols=m>1,每列一个，标准高
					h = hh;
					for(var i=1;i<=m;i++){
						x=w*(i-1);
						y=0;
						drawbox(box,i,w,h,x,y,getRandScore());			
					}
				}else{
					//m>leftCols>1,每列一个，标准高
					h = hh;
					var mm = m % leftCols;
					var c2=1;
					if(mm==0){
						//等分排列
						rows = m/leftCols;
						for(var i=1;i<=leftCols;i++){
							for(var j=1;j<=rows;j++){
								x=w*(i-1);
								h = hh/rows;
								y=h*(j-1);
								drawbox(box,c2++,w,h,x,y,getRandScore());			
							}
						}
					}else{
						//不对称排列,先填满右侧的leftCols行，再填左侧
						rows = Math.floor(m/leftCols);//每列平均数,mm<leftCols
						var rowH = new Array();
						for(var i=0;i<leftCols;i++){
							rowH[i] = rows;
						}
						var leftMM = mm;
						for(var i=leftCols;i>0;i--){
							rowH[i-1] = rowH[i-1]+1;
							leftMM--;
							if(leftMM==0){
								break;
							}
						}
						for(var i=1;i<=leftCols;i++){
							rows = rowH[i-1]; 
							for(var j=1;j<=rows;j++){
								x=w*(i-1);
								h=hh/rows;
								y=h*(j-1);
								drawbox(box,c2++,w,h,x,y,getRandScore());			
							}
						}

					}
				}
			}
			//再把整列的画满=cols * fullCols，
			var si = cols * fullCols;
			h = hh/cols;
			rows = cols;
			var c3=m;
			for(var i=1;i<=fullCols;i++){
				for(var j=1;j<=rows;j++){
					x=w*(cols-fullCols+i-1);
					y=h*(j-1);
					drawbox(box,++c3,w,h,x,y,getRandScore());			
				}
			}
		}
	}
}

function drawbox(box,i,w,h,l,t,score){
	var box = $("#box");
	var html = "<div id='box-"+i+"' class='repo' style='width:"+w+"px;height:"+h+"px;line-height:"+h+"px;left:"+l+"px;top:"+t+"px;background:"+getColor(score)+"'>repo-"+i+"("+score+"分)</div>";
	box.append(html);
}
function getRandScore(){
	var score = Math.floor(Math.random()*100+1);
	return score;
}


for(var i=1;i<=20;i++){
	$("#operation").append("<span onclick='draw("+i+")'>box"+i+"</span>&nbsp;");
}
</script>
</html>
